--- %%NOBANNER%% -->
/*-------------------<-- Start of Description-->---------------------\
| Proc contents: print the contents of the dataset; |
|---------------------<-- End of Description-->----------------------|
|--------------------------------------------------------------------|
|------------<-- Start of Files or Arguments Needed-->---------------|
| Names of different data sets must be separated by a space; |
|---------------<-- End of Files Arguments Needed-->-----------------|
|--------------------------------------------------------------------|
|----------------<-- Start of Example and Usage -->-----------------|
| Example: %prcnt(attest.covar); |
\-------------------<-- End of Example and Usage -->---------------*/
%macro cnt/parmbuff;
/*--------------------------------------------\
| Author: Duo Zhou; |
| Created: 2-27-2001 11:54pm; |
| Modified: 6-4-2001 9:41pm; |
| Purpose: Proc contents (1 or more than 1 |
| data set; |
\--------------------------------------------*/
%local _num_ _dsname_ _viewexist_ _memtype_ _tmplast_;
%let _num_=0; %let _tmplast_=&syslast;
%do %while(%length(%nrbquote(%qscan(&syspbuff, %eval(&_num_+1), %str((), )))));
%let _num_=%eval(&_num_+1);
%let _dsname_=%qscan(&syspbuff, &_num_, %str((), ));
%let _dsname_=%sysfunc(dequote(&_dsname_));
%if not (%sysfunc(exist(&_dsname_))) %then %do;
data _null_;
_dsname_="&_dsname_";
if (exist(_dsname_,"VIEW")) then call symput('_viewexist_', 1);
else call symput('_viewexist_', 0);
run;
%end;
%if (%sysfunc(exist(&_dsname_))) or (%trim(%left(&_viewexist_)) eq 1) %then %do;
%if (%sysfunc(exist(&_dsname_))) %then %let _memtype_=Data;
%else %let _memtype_= View;
%if (not %sysfunc(indexw(%quote(%upcase(%sysfunc(translate(%quote(&syspbuff),%quote( ),%quote(,()))))),NUM))) and
(not %sysfunc(indexw(%quote(%upcase(%sysfunc(translate(%quote(&syspbuff),%quote( ),%quote(,()))))),VARNUM))) and
(not %sysfunc(indexw(%quote(%upcase(%sysfunc(translate(%quote(&syspbuff),%quote( ),%quote(,()))))),NAME))) %then %do;
proc contents data=&_dsname_ memtype=all;
title1 "%center(%initcaps(Contents of %trim(%left(&_memtype_)) &_dsname_))";
run;
%end;
%else %do;
ods listing close;
proc contents data=&_dsname_ memtype=all;
ods output Attributes=_attri_ EngineHost=_engh_ VariablesAlpha=_varal_;
run;
ods listing;
%end;
%if %sysfunc(indexw(%quote(%upcase(%sysfunc(translate(%quote(&syspbuff),%quote( ),%quote(,()))))),NUM)) or
%sysfunc(indexw(%quote(%upcase(%sysfunc(translate(%quote(&syspbuff),%quote( ),%quote(,()))))),VARNUM)) %then %do;
%if (%sysfunc(exist(_attri_))) %then %do;
proc print data=_attri_(drop=member nValue1 nValue2) noobs label;
title1 "%center(%initcaps(Attributes of %trim(%left(&_memtype_)) &_dsname_))";
run;
%end;
%else %put --> Note: %trim(%left(&_memtype_)) "&_dsname_" does not have any attributes.;
%if (%sysfunc(exist(_engh_))) %then %do;
proc print data=_engh_(drop=member) noobs label;
title1 "%center(%initcaps(Engine Host of %trim(%left(&_memtype_)) &_dsname_))";
run;
%end;
%else %put --> Note: %trim(%left(&_memtype_)) "&_dsname_" does not have any info about its engine host.;
%if (%sysfunc(exist(_varal_))) %then %do;
proc sql;
create table _varal_ as
select *
from _varal_(drop=member)
order by num;
quit;
proc print data=_varal_ noobs label;
title1 "%center(%initcaps(Variables of %trim(%left(&_memtype_)) &_dsname_))";
run;
%end;
%else %put --> Note: %trim(%left(&_memtype_)) "&_dsname_" does not have any variable information available.;
%if %sysfunc(indexw(%quote(%upcase(%sysfunc(translate(%quote(&syspbuff),%quote( ),%quote(,()))))),NUM)) %then
%let syspbuff=%sysfunc(tranwrd(%quote(%upcase(&syspbuff)),%quote(NUM),%quote()));
%else %if %sysfunc(indexw(%quote(%upcase(%sysfunc(translate(%quote(&syspbuff),%quote( ),%quote(,()))))),VARNUM)) %then
%let syspbuff=%sysfunc(tranwrd(%quote(%upcase(&syspbuff)),%quote(VARNUM),%quote()));
%end;
%else %if %sysfunc(indexw(%quote(%upcase(%sysfunc(translate(%quote(&syspbuff),%quote( ),%quote(,()))))),NAME)) %then %do;
%if %sysfunc(indexw(%quote(%upcase(%sysfunc(translate(%quote(&syspbuff),%quote( ),%quote(,()))))),NAME)) %then
%let syspbuff=%sysfunc(tranwrd(%quote(%upcase(&syspbuff)),%quote(NAME),%quote()));
%if (%sysfunc(exist(_attri_))) %then %do;
proc print data=_attri_(drop=member nValue1 nValue2) noobs label;
title1 "%center(%initcaps(Attributes of %trim(%left(&_memtype_)) &_dsname_))";
run;
%end;
%else %put --> Note: %trim(%left(&_memtype_)) "&_dsname_" does not have any attributes.;
%if (%sysfunc(exist(_engh_))) %then %do;
proc print data=_engh_(drop=member) noobs label;
title1 "%center(%initcaps(Engine Host of %trim(%left(&_memtype_)) &_dsname_))";
run;
%end;
%else %put --> Note: %trim(%left(&_memtype_)) "&_dsname_" does not have any info about its engine host.;
%if (%sysfunc(exist(_varal_))) %then %do;
proc sql;
create table _varal_ as
select *
from _varal_(drop=member)
order by upcase(variable);
quit;
proc print data=_varal_ noobs label;
title1 "%center(%initcaps(Variables of %trim(%left(&_memtype_)) &_dsname_))";
run;
%end;
%else %put --> Note: %trim(%left(&_memtype_)) "&_dsname_" does not have any variable information available.;
%end;
%end;
%else %do;
%put ==> Alert! Please check your input, the data set "&_dsname_";
%put ==> doesn%str(%')t exist!;
%end;
%end;
title1 " ";
%let syslast=&_tmplast_;
%mend cnt;